package com.esyoga.yoyoga.service.impl;

import com.esyoga.yoyoga.mapper.TContractMapper;
import com.esyoga.yoyoga.mapper.TOrderMapper;
import com.esyoga.yoyoga.pojo.TContract;
import com.esyoga.yoyoga.pojo.TContractExample;
import com.esyoga.yoyoga.pojo.TOrder;
import com.esyoga.yoyoga.pojo.TOrderExample;
import com.esyoga.yoyoga.service.CoachOrderService;
import lombok.Data;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Data
@Service
public class CoachOrderServiceImpl implements CoachOrderService {

    @Resource
    private TOrderMapper tOrderMapper;

    @Resource
    TContractMapper tContractMapper;
    @Resource
    TOrderExample tOrderExample;

    @Resource
    TContractExample tContractExample;

    //查询教练的订单
    @Override
    public List<TOrder> showOrder(Integer tId) {
        TContractExample.Criteria criteriaContract = tContractExample.createCriteria();
        criteriaContract.andCSIdEqualTo(tId);
        List<TContract> tContracts = tContractMapper.selectByExample(tContractExample);
        List<Integer> ocids = new ArrayList<>();
        for(TContract c:tContracts){
            ocids.add(c.getcId());
        }
        tOrderExample.clear();
        TOrderExample.Criteria criteriaOrder = tOrderExample.createCriteria();
        criteriaOrder.andOCIdIn(ocids);
        System.out.println(ocids);
        List<TOrder> orders = tOrderMapper.selectByExample(tOrderExample);
        return orders;
    }
}
